package Main;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


import Component.MyButton;
import Component.MyForm;
import Global.GlobalGameOption;
import Global.ResourceManager;
import java.awt.Point;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;

/**
 *
 * @author Alvis
 */
public class GameMenuState extends GameState {

	Point currentMousePosition;

	public GameMenuState(Game _game) {
		super(_game);
		

		//SoundClip sound = new SoundClip("Audio/cattle.wav");
	
		//sound.clone().start();
		
		BufferedImage backImg = ResourceManager.getImage("menu/background");
		form = new MyForm(backImg, game.getWidth(), game.getHeight());

		MyButton newGame = new MyButton(ResourceManager.getImage("menu/newgame"), 100, 100);
		form.add(newGame);

		MyButton loadGame = new MyButton(ResourceManager.getImage("menu/loadgame"), 400, 100);
		form.add(loadGame);

		MyButton optionGame = new MyButton(ResourceManager.getImage("menu/option"), 250, 200);
		form.add(optionGame);

		MyButton aboutGame = new MyButton(ResourceManager.getImage("menu/about"), 250, 300);
		form.add(aboutGame);

		MyButton exitGame = new MyButton(ResourceManager.getImage("menu/exit"), 250, 400);
		form.add(exitGame);

		newGame.setMouseAdapter(new MouseAdapter() {

			@Override
			public void mouseReleased(MouseEvent e) {
				game.gameState = new GameCustomState(game);
			}
		});
		loadGame.setMouseAdapter(new MouseAdapter() {

			@Override
			public void mouseReleased(MouseEvent e) {
				//game.gameState = new GamePlayState(game);
			}
		});
		optionGame.setMouseAdapter(new MouseAdapter() {

			@Override
			public void mouseReleased(MouseEvent e) {
				game.gameState = new GameOptionState(game);
			}
		});
		aboutGame.setMouseAdapter(new MouseAdapter() {

			@Override
			public void mouseReleased(MouseEvent e) {
				game.gameState = new GameAboutSate(game);
			}
		});
		exitGame.setMouseAdapter(new MouseAdapter() {

			@Override
			public void mouseReleased(MouseEvent e) {
				game.isExit = true;
				GlobalGameOption.MUSIC.getMusic("menu").stop();
			}
		});
		GlobalGameOption.MUSIC.getMusic("menu").loop();
	}
	
}
